﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="接箍入库单录入.aspx.cs" Inherits="syc.Fc.接箍入库单录入" %>
<html>
<head>
<title></title>
<style>
a.listitem{display:block;border-top:1px solid #eeeeee;padding:2px;}
a.listitem:link {color: #333333;text-decoration: none; }
a.listitem:visited {color: #333333;text-decoration: none; }
a.listitem:hover {color: #ff9966;text-decoration: none; background-color:#d2e8ae; }
a.listitem:active {color: #ff9966;text-decoration: none; }

a.edit{display:block;height:23px;line-height:23px;}
a.edit:link {color: #333333;text-decoration: none; }
a.edit:visited {color: #333333;text-decoration: none; }
a.edit:hover {color: #6666ff;text-decoration: none; background-color:#d2e8ae; }
a.edit:active {color: #6666ff;text-decoration: none; background-color:#d2e8ae; }

</style>
</head>
<body>
<script type="text/javascript" language="javascript" src="/common.js"></script>
<form id="form1" runat="server" onsubmit="return(checkInput())">
<asp:Label ID="Label_ID" runat="server" Text="0" Visible="false"></asp:Label>
<asp:HiddenField ID="RQList" runat="server" Value="" />
<asp:HiddenField ID="GHIDList" runat="server" Value="" />
<asp:HiddenField ID="LHList" runat="server" Value="" />
<asp:HiddenField ID="ZSList" runat="server" Value="" />
<asp:HiddenField ID="JMList" runat="server" Value="" />
<asp:HiddenField ID="BeiZhu" runat="server" Value="" />

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
    ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
    SelectCommand="SELECT [ID], [名称] FROM [原料供货单位]" 
    oninserted="SqlDataSource1_Inserted" >
    <InsertParameters>
        <asp:Parameter Name="BillID" Direction="Output" Size="4" DbType="Int32"/>
    </InsertParameters>
</asp:SqlDataSource>
<div id="GHList" style="display:none; position:absolute;top:207px;left:160px; border:3px solid #ffcc00;width:120px; height:239px; overflow-y:scroll;background-color:#ffffff;">
<a class=listitem href="javascript:" onclick="setGH(-1,'');">---清空---</a>
<asp:Repeater ID="GongHuo" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
<a id='ghid_<%# Eval("ID")%>' class=listitem href="javascript:" onclick='setGH(this.id,this.innerHTML);'><%# Eval("名称")%></a>
</ItemTemplate>
</asp:Repeater>
</div>

<div id="wintop" class="wintop">油/套管接箍判定合格票</div>
<asp:Panel ID="Panel1" runat="server" CssClass="panel">

    接箍类别：<asp:DropDownList ID="LeiBie" runat="server" Width="120">
        <asp:ListItem Value="1">油管接箍(J55)</asp:ListItem>
        <asp:ListItem Value="2">套管接箍(J55)</asp:ListItem>
        <asp:ListItem Value="3">油管接箍(N80Q)</asp:ListItem>
        <asp:ListItem Value="4">套管接箍(N80Q)</asp:ListItem>
    </asp:DropDownList>
     
    <asp:Button ID="Button_Save" runat="server" Text="保 存" CssClass="button" 
        UseSubmitBehavior="False" onclick="Button_Save_Click" />
        
    <asp:Button ID="Button_PanDin" runat="server" Text="盖 章" CssClass="button" 
        UseSubmitBehavior="False" Visible="false" onclick="Button_PanDin_Click" />

    <input type="button" value="导出Excel" class="button" onclick="Export();" style="font-weight:normal" />

    <input type="button" value="关 闭" class="button" onclick="parent.swin2_close();" />
    

</asp:Panel>

<script>    putBillHead();</script>

<asp:Panel ID="Panel3" runat="server">
<style>
td{text-align:center;}
td.pane{border:.5pt solid #000000;}
div.edit{overflow:hidden; white-space:nowrap;}
</style>
<table border=0 cellpadding=0 style=border-collapse:collapse;text-align:center;font-size:11pt;>
<tr height=28>
<td colspan=6 style=font-size:24px;font-weight:bold;>
    <asp:Label ID="Label_Leibie" runat="server" Text="油管"></asp:Label>接箍判定合格票</td>
</tr>
<tr height=24>
<td colspan=6 style=padding-right:10px;text-align:right;>编号：SYC/ZJ-JZ-86</td>
</tr>
<tr height=28>
<td width=120 class=pane>钢 级</td>
<td width=120 class=pane><asp:Label ID="Label_GangJi" runat="server" Text="J55"></asp:Label></td>
<td width=120 class=pane>规 格</td>
<td width=120 class=pane><asp:Label ID="Label_GuiGe" runat="server" Text="88.9×12.5"></asp:Label></td>
<td width=120 class=pane>检验标准</td>
<td width=120 class=pane>Q/SYC-16-2008</td>
</tr>
<tr height=28>
<td class=pane>日 期</td>
<td class=pane>原料厂家</td>
<td class=pane>炉 号</td>
<td class=pane>支 数</td>
<td class=pane>重量(kg)</td>
<td class=pane>紧密距(mm)</td>
</tr>
<tr height=24>
<td class=pane><a name=rq class=edit href="javascript:" ></a></td>
<td class=pane><a name=gh class=edit href="javascript:"></a></td>
<td class=pane><a name=lh class=edit href="javascript:"></a></td>
<td class=pane><a name=zs class=edit href="javascript:"></a></td>
<td class=pane></td>
<td class=pane><a name=jm class=edit href="javascript:"></a></td>
</tr>

<tr height=24>
<td class=pane><a name=rq class=edit href="javascript:" ></a></td>
<td class=pane><a name=gh class=edit href="javascript:"></a></td>
<td class=pane><a name=lh class=edit href="javascript:"></a></td>
<td class=pane><a name=zs class=edit href="javascript:"></a></td>
<td class=pane></td>
<td class=pane><a name=jm class=edit href="javascript:"></a></td>
</tr>

<tr height=24>
<td class=pane><a name=rq class=edit href="javascript:" ></a></td>
<td class=pane><a name=gh class=edit href="javascript:"></a></td>
<td class=pane><a name=lh class=edit href="javascript:"></a></td>
<td class=pane><a name=zs class=edit href="javascript:"></a></td>
<td class=pane></td>
<td class=pane><a name=jm class=edit href="javascript:"></a></td>
</tr>

<tr height=24>
<td class=pane><a name=rq class=edit href="javascript:" ></a></td>
<td class=pane><a name=gh class=edit href="javascript:"></a></td>
<td class=pane><a name=lh class=edit href="javascript:"></a></td>
<td class=pane><a name=zs class=edit href="javascript:"></a></td>
<td class=pane></td>
<td class=pane><a name=jm class=edit href="javascript:"></a></td>
</tr>

<tr height=24>
<td class=pane><a name=rq class=edit href="javascript:" ></a></td>
<td class=pane><a name=gh class=edit href="javascript:"></a></td>
<td class=pane><a name=lh class=edit href="javascript:"></a></td>
<td class=pane><a name=zs class=edit href="javascript:"></a></td>
<td class=pane></td>
<td class=pane><a name=jm class=edit href="javascript:"></a></td>
</tr>

<tr height=24>
<td class=pane><a name=rq class=edit href="javascript:" ></a></td>
<td class=pane><a name=gh class=edit href="javascript:"></a></td>
<td class=pane><a name=lh class=edit href="javascript:"></a></td>
<td class=pane><a name=zs class=edit href="javascript:"></a></td>
<td class=pane></td>
<td class=pane><a name=jm class=edit href="javascript:"></a></td>
</tr>

<tr height=24>
<td class=pane><a name=rq class=edit href="javascript:" ></a></td>
<td class=pane><a name=gh class=edit href="javascript:"></a></td>
<td class=pane><a name=lh class=edit href="javascript:"></a></td>
<td class=pane><a name=zs class=edit href="javascript:"></a></td>
<td class=pane></td>
<td class=pane><a name=jm class=edit href="javascript:"></a></td>
</tr>

<tr height=24>
<td class=pane><a name=rq class=edit href="javascript:" ></a></td>
<td class=pane><a name=gh class=edit href="javascript:"></a></td>
<td class=pane><a name=lh class=edit href="javascript:"></a></td>
<td class=pane><a name=zs class=edit href="javascript:"></a></td>
<td class=pane></td>
<td class=pane><a name=jm class=edit href="javascript:"></a></td>
</tr>

<tr height=24>
<td class=pane><a name=rq class=edit href="javascript:" ></a></td>
<td class=pane><a name=gh class=edit href="javascript:"></a></td>
<td class=pane><a name=lh class=edit href="javascript:"></a></td>
<td class=pane><a name=zs class=edit href="javascript:"></a></td>
<td class=pane></td>
<td class=pane><a name=jm class=edit href="javascript:"></a></td>
</tr>

<tr height=24>
<td class=pane><a name=rq class=edit href="javascript:" ></a></td>
<td class=pane><a name=gh class=edit href="javascript:"></a></td>
<td class=pane><a name=lh class=edit href="javascript:"></a></td>
<td class=pane><a name=zs class=edit href="javascript:"></a></td>
<td class=pane></td>
<td class=pane><a name=jm class=edit href="javascript:"></a></td>
</tr>

<tr height=24>
<td class=pane>合 计：</td>
<td class=pane></td>
<td class=pane></td>
<td class=pane><asp:Label ID="Label_Zhi" runat="server" Text="0"></asp:Label></td>
<td class=pane><asp:Label ID="Label_Zhong" runat="server" Text="0"></asp:Label></td>
<td class=pane></td>
</tr>
<tr height=50>
<td class=pane>备 注：</td>
<td colspan=5 class=pane style="text-align:left;"><a id=BZ class=edit href="javascript:"style="height:49px;line-height:20px;text-align:left;" ><%=this.BeiZhu.Value%></a></td>
</tr>
<tr height=24>
<td></td>
<td></td>
<td></td>
<td></td>
<td style=text-align:right;>判定：<asp:Label ID="Label_ZhiJianYuan" runat="server" Text=""></asp:Label></td>
<td></td>
</tr>
</table>
</asp:Panel>
<div style="text-align:right;height:105px;margin-top:-95px;margin-right:20px;">
<asp:Image ID="PDZ" runat="server" ImageUrl="/images/pdz.png" Visible="false" />
</div>
<script>    putBillFoot();</script>

</form>

<form id="form2" method="post" action="/PageExport.ashx">
<input type="hidden" name="filename" value="判定合格票.xls" />
<input type="hidden" name="content" value="" />
</form>


<script>
var notice = '<%=this.Notice %>';
if (notice != '') {
    parent.showmsgbox(notice);
}


//数据列初始化
var readonly = false;
if (document.getElementById("PDZ")) {
    readonly = true;
}
else {
    var alla = document.getElementsByTagName("a");
    for (var i = 0; i < alla.length; i++) {
        if (alla[i].className == "edit") {
            
            alla[i].contentEditable = true;
        }
    }
}
var RQList = document.getElementById("RQList").value.split("|");
var GHIDList = document.getElementById("GHIDList").value.split("|");
var LHList = document.getElementById("LHList").value.split("|");
var ZSList = document.getElementById("ZSList").value.split("|");
var JMList = document.getElementById("JMList").value.split("|");

var curr_gh;//当前录入的供货商

//设置供货商
function setGH(n, txt) {
    if(n!=-1)
        GHIDList[curr_gh.parentNode.parentNode.rowIndex - 4] = n.split("_")[1];
    else
        GHIDList[curr_gh.parentNode.parentNode.rowIndex - 4] = "";
    curr_gh.innerHTML = txt;
}

//初始化日期列
var rqs = document.getElementsByName("rq");

for (var i = 0; i < rqs.length; i++) {
    if (!readonly) {
        rqs[i].onfocus = function() {
            makecalendar(this.innerHTML, this);
            this.blur();
        };
    }
    if (i < RQList.length)
        rqs[i].innerHTML = RQList[i];
}

//初始化供货商列
var ghs = document.getElementsByName("gh");
for (var i = 0; i < ghs.length; i++) {
    if (!readonly) {
        ghs[i].onfocus = ghs[i].onclick = function() {
            curr_gh = this;
            setTimeout("document.getElementById('GHList').style.display = 'block'", 200);
            this.blur();
        };
    }
    if (i < GHIDList.length && GHIDList[i]!=0)
        ghs[i].innerHTML = document.getElementById("ghid_" + GHIDList[i]).innerHTML;
}

//初始化炉号列
var lhs = document.getElementsByName("lh");
for (var i = 0; i < lhs.length; i++) {
    lhs[i].onkeydown = function(e) {
        if (!e) e = window.event;
        if (e.keyCode == 13) {
            e.keyCode = 9;
        }
    };
    if (i < LHList.length)
        lhs[i].innerHTML = LHList[i];
}

//初始化支数列
var zss = document.getElementsByName("zs");
for (var i = 0; i < zss.length; i++) {
    zss[i].onkeydown = function(e) {
    if (!e) e = window.event;
        if (e.keyCode == 13) {
            e.keyCode = 9;
        }
    };
    zss[i].onblur = function() {
        calc();
    }
    if (i < ZSList.length)
        zss[i].innerHTML = ZSList[i];
}

//初始化紧密距列
var jms = document.getElementsByName("jm");
for (var i = 0; i < jms.length; i++) {
    jms[i].onkeydown = function(e) {
        if (!e) e = window.event;
        var tag = e.srcElement;
        if (!tag) tag = e.target;
        if (e.keyCode == 13) {
            var n = tag.parentNode.parentNode.rowIndex - 4;
            if (n < lhs.length - 1) {
                lhs[n + 1].focus();
            }
            return false;
        }
    };
    if (i < JMList.length)
        jms[i].innerHTML = JMList[i];
}

//
document.getElementById("LeiBie").onchange = function() {
    if (this.value == "1" || this.value == "3") {
        document.getElementById("Label_GuiGe").innerHTML = "88.9×12.5";
        document.getElementById("Label_Leibie").innerHTML = "油管";
    }
    else {
        document.getElementById("Label_GuiGe").innerHTML = "153.67×13";
        document.getElementById("Label_Leibie").innerHTML = "套管";
    }
    if (this.value == "1" || this.value == "2") {
        document.getElementById("Label_GangJi").innerHTML = "J55";
    }
    else {
        document.getElementById("Label_GangJi").innerHTML = "N80";
    }
    calc();
};

document.getElementById("LeiBie").onchange();
document.body.onclick = function() {

    document.getElementById("GHList").style.display = "none";
};


document.onkeydown = function(e) {
    var aas;
    var n;
    if (!e) e = window.event;
    var tag = e.srcElement;
    if (!tag) tag = e.target;

    if (!tag.name) return;
    else if (tag.name == "lh") aas = lhs;
    else if (tag.name == "zs") aas = zss;
    else if (tag.name == "jm") aas = jms;

    if (e.keyCode == 40) {//向下方向键
        n = tag.parentNode.parentNode.rowIndex - 4;
        if (n < aas.length - 1) {
            aas[n + 1].focus();
        }
        return false;
    }
    else if (e.keyCode == 38) {//向上方向键
        n = tag.parentNode.parentNode.rowIndex - 4;
        if (n > 0) {
            aas[n - 1].focus();
        }
        return false;
    }
}

//计算合计
function calc() {
    var zz=0;
    var zs=0;
    var tzs = 0;
    if (document.getElementById("Label_Leibie").innerHTML == "油管") {
        zz = 23;
    }
    else {
        zz = 61;
    }
    for (var i = 0; i < zss.length; i++) {
        zs = Number(zss[i].innerHTML);
        if (zs != NaN && zs > 0) {
            zss[i].parentNode.nextSibling.innerHTML = zs * zz / 10;
            tzs += zs;
        }
        else {
            zss[i].parentNode.nextSibling.innerHTML = "";
        }
        
    }
    document.getElementById("Label_Zhi").innerHTML = tzs;
    document.getElementById("Label_Zhong").innerHTML = tzs * zz / 10;
}
calc();

//输入检测
function checkInput() {
    for (var i = 0; i < rqs.length; i++) {
        RQList[i] = rqs[i].innerHTML;
        LHList[i] = lh[i].innerHTML;
        ZSList[i] = zs[i].innerHTML;
        JMList[i] = jm[i].innerHTML;
        if (GHIDList[i] == undefined || GHIDList[i] == "") GHIDList[i] = "";
    }
    document.getElementById("RQList").value = RQList.join("|");
    document.getElementById("GHIDList").value = GHIDList.join("|");
    document.getElementById("LHList").value = LHList.join("|");
    document.getElementById("ZSList").value = ZSList.join("|");
    document.getElementById("JMList").value = JMList.join("|");
    document.getElementById("BeiZhu").value = document.getElementById("BZ").innerHTML;
}

function makecalendar(d, o) {
    obj = o;
    idate = makedate(d);
    cdate = new Date(idate.getFullYear(), idate.getMonth(), 1);
    ds.style.left = getObjectLeft(o) + "px";
    var top = getObjectTop(o) + 25;
    if(top>360)top=360
    ds.style.top = top + "px";
    ds.style.display = 'block';
    showcalendar();
}


//导出Excel
function Export() {
    form2.content.value =
"<html xmlns:o='urn:schemas-microsoft-com:office:office'\nxmlns:x='urn:schemas-microsoft-com:office:excel'\nxmlns='http://www.w3.org/TR/REC-html40'>\n<head>\n<meta http-equiv=Content-Type content='text/html; charset=utf-8'>\n<style>\n<!--table\n@page\n{mso-header-data:;\nmso-footer-data:;\nmargin:.79in .31in .79in .31in;\nmso-header-margin:.51in;\nmso-footer-margin:.51in;\nmso-page-orientation:landscape;\nmso-horizontal-page-align:center;\n}\n-->\n</style>\n<!--[if gte mso 9]><xml>\n<x:ExcelWorkbook>\n<x:ExcelWorksheets>\n<x:ExcelWorksheet>\n<x:Name>生产进度日报表</x:Name>\n<x:WorksheetOptions>\n<x:DefaultRowHeight>285</x:DefaultRowHeight>\n<x:Print>\n<x:ValidPrinterInfo/>\n<x:Scale>100</x:Scale>\n<x:PaperSizeIndex>9</x:PaperSizeIndex>\n<x:HorizontalResolution>200</x:HorizontalResolution>\n<x:VerticalResolution>200</x:VerticalResolution>\n</x:Print>\n<x:Selected/>\n<x:Panes>\n<x:Pane>\n<x:Number>3</x:Number>\n<x:ActiveRow>0</x:ActiveRow>\n<x:ActiveCol>0</x:ActiveCol>\n</x:Pane>\n</x:Panes>\n</x:WorksheetOptions>\n</x:ExcelWorksheet>\n</x:ExcelWorkbook>\n</xml><![endif]-->\n</head>\n<body>"
            + document.getElementById("Panel3").innerHTML.replace(/<a [^>]*>/gi, "").replace(/<\/a>/gi, "");
            + "</body></html>";
    form2.submit();
}
</script>

</body>
</html>